package de.bbl.android.classes;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

import de.bbl.android.tools.Tools;

public class PlayDay {
	private String playDayNumber;
	private String playDayDateFrom;
	private String playDayDateTil;
	
	public PlayDay(String number, String from, String til) {
		setPlayDayDateFrom(from);
		setPlayDayDateTil(til);
		setPlayDayNumber(number);
	}

	public String getPlayDayNumber() {
		return playDayNumber;
	}

	public void setPlayDayNumber(String playDayNumber) {
		this.playDayNumber = playDayNumber;
	}

	public String getPlayDayDateFrom() {
		return playDayDateFrom;
	}

	public void setPlayDayDateFrom(String playDayDateFrom) {
		SimpleDateFormat parserSDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
		Date tempDate = null;
		String retval = playDayDateFrom;
		try {
			parserSDF.setTimeZone(TimeZone.getTimeZone("UTC"));
			tempDate = parserSDF.parse(playDayDateFrom.toString());
			parserSDF = new SimpleDateFormat("dd.MM.yyyy HH:mm");
			parserSDF.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
			retval = parserSDF.format(tempDate);
		} catch (Exception e) {
        	Tools.AppendToErrorFile(e.getMessage());
            // e.printStackTrace();
		}
		this.playDayDateFrom = retval;
	}

	public String getPlayDayDateTil() {
		return playDayDateTil;
	}

	public void setPlayDayDateTil(String playDayDateTil) {
		SimpleDateFormat parserSDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
		Date tempDate = null;
		String retval = playDayDateTil;
		try {
			parserSDF.setTimeZone(TimeZone.getTimeZone("UTC"));
			tempDate = parserSDF.parse(playDayDateTil.toString());
			parserSDF = new SimpleDateFormat("dd.MM.yyyy HH:mm");
			// parserSDF.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
			retval = parserSDF.format(tempDate);
		} catch (Exception e) {
        	Tools.AppendToErrorFile(e.getMessage());
            // e.printStackTrace();
		}
		this.playDayDateTil = retval;
	}
	
}
